package com.cskaoyan.bean.vo;

import com.cskaoyan.bean.po.*;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class WXGoodsDetailVo {
    /**
     * specificationList : [{"valueList":[{"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/t1ti75ac62op1f0gn609.jpg","deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"specification":"颜色","updateTime":"2022-09-09 09:34:58","id":311,"value":"墨绿色"},{"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/aiveihlu6dmn1migbyi7.jpg","deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"specification":"颜色","updateTime":"2022-09-09 09:34:58","id":312,"value":"远峰蓝"}],"name":"颜色"}]
     * groupon : []
     * issue : [{"deleted":false,"question":"购买运费如何收取？1","answer":"单笔订单金额（不含运费）满88元免邮费；不满88元，每单收取10元运费。\n(港澳台地区需满10\n加十块1\n加1000","addTime":"2018-02-01 00:00:00","updateTime":"2022-09-08 17:39:44","id":1},{"deleted":false,"question":"使用什么快递发货？","answer":"严选默认使用顺丰快递发货（个别商品使用其他快递），配送范围覆盖全国大部分地区（港澳台地区除","addTime":"2018-02-01 00:00:00","updateTime":"2022-09-08 09:13:23","id":2},{"deleted":false,"question":"如何申请退货？","answer":"1.自收到商品之日起30日内，顾客可申请无忧退货，退款将原路返还，不同的银行处理时间不同，","addTime":"2018-02-01 00:00:00","updateTime":"2018-02-01 00:00:00","id":3},{"deleted":false,"question":"1","answer":"1","addTime":"2022-09-07 21:20:57","updateTime":"2022-09-07 21:20:57","id":14}]
     * userHasCollect : 0
     * comment : {"data":[],"count":0}
     * share : true
     * attribute : []
     * brand : {"floorPrice":39,"picUrl":"http://yanxuan.nosdn.127.net/4e93ea29b1d06fabfd24ba68a9b20a34.jpg","deleted":false,"addTime":"2018-02-01 00:00:00","sortOrder":35,"name":"Under Armour制造商","updateTime":"2018-02-01 00:00:00","id":1026001,"desc":"严选为甄选优质好袜，走访东北、新疆等产袜基地，\n最终选定Under Armour品牌的合作制造商，\n从原料、工艺、品质多维度筛选监制，保证好品质。"}
     * productList : [{"number":0,"deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"price":0,"updateTime":"2022-09-09 09:34:58","id":301,"specifications":["墨绿色"],"url":""},{"number":0,"deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"price":0,"updateTime":"2022-09-09 09:34:58","id":302,"specifications":["远峰蓝"],"url":""}]
     * info : {"brief":"超大气","keywords":"","addTime":"2022-09-09 09:34:57","goodsSn":"111","updateTime":"2022-09-09 09:34:57","isNew":true,"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/b4qvclguh9q0gf9d4thr.jpg","unit":"10件","deleted":false,"brandId":1026001,"sortOrder":100,"name":"iphone14pro","counterPrice":7999,"id":1181050,"detail":"<p>品质超好<\/p>","isOnSale":true,"retailPrice":0,"categoryId":1036053,"gallery":["http://182.92.235.201:8083/wx/storage/fetch/l5wadz0nmvdysvh63rzi.jpg"],"isHot":true}
     */
    //查表market_goods_specification
    private List<SpecificationListEntity> specificationList = new ArrayList<>();
    //不用管
    private Integer[] groupon = {};
    //查表market_issue
    private List<IssueEntity> issue = new ArrayList<>();
    //实际为布尔类型，0代表否，1代表是
    //TODO 查market_collect
    private int userHasCollect;
    //查表market_comment
    private CommentEntity comment = new CommentEntity();
    //TODO 未找到位置
    private Boolean share = true;
    //查表market_goods_attribute
    private List<MarketGoodsAttribute> attribute;
    //查表market_brand
    private BrandEntity brand = new BrandEntity();
    //查表market_goods_product
    private List<ProductListEntity> productList = new ArrayList<>();
    //查表market_goods
    private InfoEntity info = new InfoEntity();


    //给表SpecificationListEntity赋值
    public void setSpecificationEntity(List<MarketGoodsSpecification> lists,String specification){
        SpecificationListEntity specificationListEntity = new SpecificationListEntity();
        specificationListEntity.setName(specification);

        List<ValueListEntity> values = new ArrayList<>();
        for (MarketGoodsSpecification list : lists) {
            ValueListEntity valueListEntity = new ValueListEntity();
            BeanUtils.copyProperties(list,valueListEntity);
            values.add(valueListEntity);
        }

        specificationListEntity.setValueList(values);
        specificationList.add(specificationListEntity);
    }

    //给表IssueEntity赋值
    public void setIssueEntity(MarketIssue marketIssue){
        IssueEntity issueEntity = new IssueEntity();
        BeanUtils.copyProperties(marketIssue,issueEntity);
        issue.add(issueEntity);
    }

    //给CommentEntity赋值
    public void setCommentEntity(List<MarketComment> comments,Integer total){
        comment.setCount(total);
        comment.setData(comments);
    }

    //给BrandEntity赋值
    public void setBrandEntity(MarketBrand marketBrand){
        if(marketBrand != null){
            BeanUtils.copyProperties(marketBrand,brand);
        }
    }

    //给表ProductListEntity
    public void setProductListEntity(MarketGoodsProduct goodsProduct){
        ProductListEntity productListEntity = new ProductListEntity();
        BeanUtils.copyProperties(goodsProduct,productListEntity);
        productList.add(productListEntity);
    }

    //给InfoEntity赋值
    public void setInfoEntity(MarketGoods marketGoods){
        BeanUtils.copyProperties(marketGoods,info);
    }

    @Data
    public class SpecificationListEntity {
        /**
         * valueList : [{"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/t1ti75ac62op1f0gn609.jpg","deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"specification":"颜色","updateTime":"2022-09-09 09:34:58","id":311,"value":"墨绿色"},{"picUrl":"http://182.92.235.201:8083/wx/storage/fetch/aiveihlu6dmn1migbyi7.jpg","deleted":false,"addTime":"2022-09-09 09:34:58","goodsId":1181050,"specification":"颜色","updateTime":"2022-09-09 09:34:58","id":312,"value":"远峰蓝"}]
         * name : 颜色
         */
        private List<ValueListEntity> valueList;
        private String name;

    }

    @Data
    public class ValueListEntity {
        /**
         * picUrl : http://182.92.235.201:8083/wx/storage/fetch/t1ti75ac62op1f0gn609.jpg
         * deleted : false
         * addTime : 2022-09-09 09:34:58
         * goodsId : 1181050
         * specification : 颜色
         * updateTime : 2022-09-09 09:34:58
         * id : 311
         * value : 墨绿色
         */
        private String picUrl;
        private Boolean deleted;
        private Date addTime;
        private Integer goodsId;
        private String specification;
        private Date updateTime;
        private Integer id;
        private String value;
    }


    @Data
    public class IssueEntity {
        /**
         * deleted : false
         * question : 购买运费如何收取？1
         * answer : 单笔订单金额（不含运费）满88元免邮费；不满88元，每单收取10元运费。
         (港澳台地区需满10
         加十块1
         加1000
         * addTime : 2018-02-01 00:00:00
         * updateTime : 2022-09-08 17:39:44
         * id : 1
         */
        private Boolean deleted;
        private String question;
        private String answer;
        private Date addTime;
        private Date updateTime;
        private Integer id;
    }

    @Data
    public class CommentEntity {
        /**
         * data : []
         * count : 0
         */
        private List<MarketComment> data;
        private int count;

    }

    @Data
    public class BrandEntity {
        /**
         * floorPrice : 39.0
         * picUrl : http://yanxuan.nosdn.127.net/4e93ea29b1d06fabfd24ba68a9b20a34.jpg
         * deleted : false
         * addTime : 2018-02-01 00:00:00
         * sortOrder : 35
         * name : Under Armour制造商
         * updateTime : 2018-02-01 00:00:00
         * id : 1026001
         * desc : 严选为甄选优质好袜，走访东北、新疆等产袜基地，
         最终选定Under Armour品牌的合作制造商，
         从原料、工艺、品质多维度筛选监制，保证好品质。
         */
        private BigDecimal floorPrice;
        private String picUrl;
        private Boolean deleted;
        private Date addTime;
        private Byte sortOrder;
        private String name;
        private Date updateTime;
        private Integer id;
        private String desc;

    }

    @Data
    public class ProductListEntity {
        /**
         * number : 0
         * deleted : false
         * addTime : 2022-09-09 09:34:58
         * goodsId : 1181050
         * price : 0.0
         * updateTime : 2022-09-09 09:34:58
         * id : 301
         * specifications : ["墨绿色"]
         * url :
         */
        private Integer number;
        private Boolean deleted;
        private Date addTime;
        private Integer goodsId;
        private BigDecimal price;
        private Date updateTime;
        private Integer id;
        private List<String> specifications;
        private String url;
    }

    @Data
    public class InfoEntity {
        /**
         * brief : 超大气
         * keywords :
         * addTime : 2022-09-09 09:34:57
         * goodsSn : 111
         * updateTime : 2022-09-09 09:34:57
         * isNew : true
         * picUrl : http://182.92.235.201:8083/wx/storage/fetch/b4qvclguh9q0gf9d4thr.jpg
         * unit : 10件
         * deleted : false
         * brandId : 1026001
         * sortOrder : 100
         * name : iphone14pro
         * counterPrice : 7999.0
         * id : 1181050
         * detail : <p>品质超好</p>
         * isOnSale : true
         * retailPrice : 0.0
         * categoryId : 1036053
         * gallery : ["http://182.92.235.201:8083/wx/storage/fetch/l5wadz0nmvdysvh63rzi.jpg"]
         * isHot : true
         */
        private String brief;
        private String keywords;
        private Date addTime;
        private String goodsSn;
        private Date updateTime;
        private Boolean isNew;
        private String picUrl;
        private String unit;
        private Boolean deleted;
        private Integer brandId;
        private Short sortOrder;
        private String name;
        private BigDecimal counterPrice;
        private Integer id;
        private String detail;
        private Boolean isOnSale;
        private BigDecimal retailPrice;
        private Integer categoryId;
        private List<String> gallery;
        private Boolean isHot;
    }
}
